using Microsoft.Practices.EnterpriseLibrary.ExceptionHandling;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace Sandia.MVCFramework.Common
{
    /// <summary>
    /// A custom exception formatter that formats
    /// excpetion to only write out user readable message
    /// portion of the exception
    /// </summary>
    public class UserFriendlyExceptionFormatter: TextExceptionFormatter
    {
        /// <summary>
        /// Overriden to prevent parent class from writing anything out
        /// </summary>
        /// <param name="writer"></param>
        /// <param name="exception"></param>
        public UserFriendlyExceptionFormatter(TextWriter writer, Exception exception): base(writer, exception)
        {
        }

        /// <summary>
        /// Overriden to prevent parent class from writing anything out
        /// </summary>
        protected override void Indent()
        {
        }

        /// <summary>
        /// Overriden to prevent parent class from writing anything out
        /// </summary>
        /// <param name="additionalInformation"></param>
        protected override void WriteAdditionalInfo(System.Collections.Specialized.NameValueCollection additionalInformation)
        {            
        }

        /// <summary>
        /// Overriden to prevent parent class from writing anything out
        /// </summary>
        /// <param name="utcNow"></param>
        protected override void WriteDateTime(DateTime utcNow)
        {            
        }

        /// <summary>
        /// Overriden to prevent parent class from writing anything out
        /// </summary>
        protected override void WriteDescription()
        {         
        }

        /// <summary>
        /// Overriden to limit to writing out just user readable
        /// message portion of exception
        /// </summary>
        /// <param name="exceptionToFormat"></param>
        /// <param name="outerException"></param>
        protected override void WriteException(Exception exceptionToFormat, Exception outerException)
        {
            this.Writer.WriteLine(exceptionToFormat.Message);
        }

        /// <summary>
        /// Overriden to prevent parent class from writing anything out
        /// </summary>
        /// <param name="exceptionType"></param>
        protected override void WriteExceptionType(Type exceptionType)
        {            
        }

        /// <summary>
        /// Overriden to prevent parent class from writing anything out
        /// </summary>
        /// <param name="fieldInfo"></param>
        /// <param name="value"></param>
        protected override void WriteFieldInfo(System.Reflection.FieldInfo fieldInfo, object value)
        {            
        }

        /// <summary>
        /// Overriden to prevent parent class from writing anything out
        /// </summary>
        /// <param name="helpLink"></param>
        protected override void WriteHelpLink(string helpLink)
        {            
        }

        /// <summary>
        /// Overriden to prevent parent class from writing anything out
        /// </summary>
        /// <param name="message"></param>
        protected override void WriteMessage(string message)
        {            
        }

        /// <summary>
        /// Overriden to prevent parent class from writing anything out
        /// </summary>
        /// <param name="propertyInfo"></param>
        /// <param name="value"></param>
        protected override void WritePropertyInfo(System.Reflection.PropertyInfo propertyInfo, object value)
        {            
        }

        /// <summary>
        /// Overriden to prevent parent class from writing anything out
        /// </summary>
        /// <param name="source"></param>
        protected override void WriteSource(string source)
        {            
        }

        /// <summary>
        /// Overriden to prevent parent class from writing anything out
        /// </summary>
        /// <param name="stackTrace"></param>
        protected override void WriteStackTrace(string stackTrace)
        {            
        }
    }
}
